package net.rlair.sbdemo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(2)
public class Penghaohuan2 {

    @Pointcut("execution(public * net.rlair.sbdemo.controller.ZhaozichenController.list())")
    public void pointCut() {}

    @AfterThrowing("pointCut()")
    public void afterThrowing(final JoinPoint joinPoint) {
        System.out.println("after throwing2..." + joinPoint.toString());
    }

    @Around("pointCut()")
    public Object around(final ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around before execution..." + joinPoint.toString());
        final Object result = joinPoint.proceed();
        System.out.println("around after execution..." + joinPoint.toString());
        return result;
    }
}
